package com.longtop.framework.sys.flow.web;

import java.util.List;

import org.apache.commons.lang.StringUtils;

import com.longtop.framework.base.BaseAction;
import com.longtop.framework.base.BaseService;
import com.longtop.framework.util.BeanUtil;
import com.longtop.framework.util.WebUtil;
import com.longtop.intelliweb.action.IInitContext;
import com.longtop.intelliweb.view.Dataset;

/**
 * 请假流程--审批
 * 
 * @author 胡砥峰
 * 
 */
public class LeaveViewAction extends BaseAction {

	private final static String DATASET_LEAVE = "Dataset_FlowLeave";

	/**
	 * JSP页面初始化方法
	 */
	public void init(IInitContext context) {
		super.init(context);

		// 获取页面上的dataset的结构,验证数据集对象是否存在
		Dataset leaveDataset = (Dataset) context.getDataset(DATASET_LEAVE);
		if (!WebUtil.validateDatasetExist(this, leaveDataset, DATASET_LEAVE)) {
			return;
		}

		BaseService baseService = this.getBean(BaseService.BEAN_ID);

		String instanceId = StringUtils.trimToEmpty(context.getRequest().getParameter("instanceId"));
		List leaveList = baseService.queryAll("from TSysFlowLeave where instanceId='" + instanceId + "'");

		try {
			BeanUtil.listToDataset(leaveList, leaveDataset);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}